%%%%%%%%%%%%%%%%%%%%%%%
%% TABLE O EQUATIONS %%
%%%%%%%%%%%%%%%%%%%%%%%

%% use tocloft for easily creating new lists of things
\usepackage{tocloft}
%% use xstring for string modification functionality
\usepackage{xstring}

%% make the @ symbol a letter, changing its category code
\makeatletter

\numberwithin{equation}{section}

%% "we use this for our refernces as well" (???)

%\AtBeginDocument{%
%  \renewcommand{\ref}[1]{%
%    \mbox{\autoref{#1}}%
%  }%
%}

%% define heading for list of equations
\newcommand{\listequationsname}{List of Equations}
%% tell tocloft what shall be numbered (myequations) and
%% under what list (equ)
\newlistof{myequations}{equ}{\listequationsname}
%% define the custom command for adding equations to the
%% list of equations
\newcommand{\myequations}[1]{%
% add an item in the equ list
\addcontentsline{equ}{myequations}{%
  \protect\numberline{\theequation}#1}%
}

%% set the width of numbers in the table of equations
%% (optional)

%\setlength{\cftmyequationsnumwidth}{3em}

%%% Redefine equations to add an entry in a list of
%%% equations to be displayed in the document somewhere.

%% store the current equation environment
\let\oldequation=\equation%
\let\endoldequation=\endequation%
\AtBeginDocument{\let\oldlabel=\label}% \AtBeginDocument because hyperref redefines \label

%% define a new label command, which removes the "eq:" part
%% in the label and add that string as label of things to
%% the list of equations, instead of the string with "eq:"
\newcommand{\mynewlabel}[1]{%
  \StrBehind{#1}{eq:}[\Str]% remove "eq:" from labels
  %% make \mynewlabel use \myequations to add an enty in the
  %% list of equations.
  \myequations{\Str}\oldlabel{#1}%
}

%% redefine the equation environment
\renewenvironment{equation}{%
  %% use the old beginning
  \oldequation%
  %% add an entry in the list of equations using a custom
  %% command
  \let\label\mynewlabel%
}{%
  %% use the old ending
  \endoldequation%
}

%% make the @ symbol an "other", changing its category code
%% back
\makeatother
